package com.gucheng;

import java.util.Scanner;

/**
 * quickSort（快排）
 */
public class QuickSortMain {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] q = new int[n];
        for (int i = 0; i < n; i++) {
            q[i] = sc.nextInt();
        }
        quickSort(q, 0, n - 1);
        for (int i = 0; i < n; i++) {
            System.out.println(q[i] + "");
        }
    }
    public static void quickSort(int[] q, int l, int r) {
        if(l >= r) return;
        //x为基准,i为左指针,j为右指针
        int x = q[(l+r)/2],i = l - 1, j = r + 1;
        while(i < j) {
            //i<x会一直加，直到等于x
            while (q[++i] < x);
            //j>x会一直减，直到等于x
            while (q[--j] > x);
            if(i < j) {
                int t = q[i];
                q[i] = q[j];
                q[j] = t;
            }
        }
        quickSort(q, l, j);
        quickSort(q, j + 1, r);
    }
}
